<template>
    <!--    <div>载体</div>-->
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
            <el-form-item label="任务名称" prop="taskName">
                <el-input v-model="queryParams.taskName" placeholder="请输入任务名称" clearable style="width: 240px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8" ref="refbut">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd">新增</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table ref="table" v-loading="loading" :data="dataList" :height="tableHeight"
            @selection-change="handleSelectionChange" border stripe>
            <el-table-column label="序号" sortable align="center" type="index" prop="id" />
            <el-table-column label="任务名称" prop="taskName" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="四性标识" prop="schemeCode" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="定时任务表达式" prop="timeDtask" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="状态" prop="status" align="center">
                <template slot-scope="scope">
                    {{ scope.row.status==0?'未开启':'已开启'}}
                </template>
            </el-table-column>
            <el-table-column label="操作" align="center" width="300">
                <template slot-scope="scope">
                    <el-button plain type="success" size="mini" @click="handleUpdate(scope.row)">修改</el-button>
                    <el-button plain type="danger" size="mini" @click="handleDelete(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />

        <deitBase v-if="deitOpen" :deitOpen="deitOpen" @closeDelDialog="closeDelDialog" @addsubmitForm="addsubmitForm" :Id="Id"></deitBase>
    </div>
</template>
    
<script>
import estimateTableHeight from "@/mixins/estimateTableHeight";
import {regularInspectionsList,regularInspectionsInfoDetele} from '@/api/cqbc/inspectionData/inspection.js'
import { getBackDaLists,deleteBack,backDa} from "@/api/cqbc/backupRestore/databaseManagement.js"
import deitBase from "@/views/cqbc/inspectionData/inspection/deitBase.vue"
export default {
    mixins: [estimateTableHeight], // 混入方法
    archive_Dicts: ['CARRIER_TYPE'],
    components:{
        deitBase
    },
    data() {
        return {
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            dataList: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                taskName:undefined
            },

            Id:undefined,
            deitOpen:false,
          
        }
    },
    created() {
        this.getList()
    },
    methods: {
        getList() {
            regularInspectionsList(this.queryParams).then(response => {
                this.dataList = response.rows
                this.total = response.total
                this.loading = false
            })
        },

        handleQuery(){
            this.getList();
        },
        resetQuery(){
            this.queryParams= {
                pageNum: 1,
                pageSize: 10,
                taskName:undefined
            },
            this.getList();
        },
        table_index(index) {
            return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
       
        // 新增
        handleAdd() {
            this.deitOpen = true
            this.Id=undefined
        },
        // 修改
        handleUpdate(row) {
            this.deitOpen = true
            this.Id= row.id
        },
        addsubmitForm() {
            this.deitOpen = false;
            this.getList();
        },
        cancelForm() {
            this.open = false
        },
        // 删除
        handleDelete(row) {
            console.log(row,"sdklfjksdlfjlsdfjkl")
            const id = row.id
            this.$modal.confirm('是否确认删除备份名称为"' + row.taskName + '"的数据项？').then(function () { }).then(() => {
                regularInspectionsInfoDetele(id).then(res => {
                    if (res.code == "200") {
                        this.$modal.msgSuccess("删除成功");
                        this.getList();
                    }
                })
            }).catch(() => { });
        },

        closeDelDialog(){
            this.deitOpen=false;
        },
    }
}
</script>
    
<style></style>
    